<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../../Css/style.css"/>
    <script type="text/javascript" src="../../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../../Js/ckform.js"></script>
    <script type="text/javascript" src="../../Js/common.js"></script>
    <script type="text/javascript" src="../../Js/cusz/resourceUtils.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script>
        $(function () {
            $('#backid').click(function () {
                window.location.href = "index.html";
            });

            // 保存系统资源
            $("#b1").click(function () {
                // 不使用表单方式提交请求
                event.preventDefault();
                // 非空校验
                let mUrl = $("input[name='mUrl']").val();
                if (mUrl === null || mUrl === undefined || mUrl === '') {
                    alert("url 不能为空!");
                    return;
                }
                // 唯一性校验
                // mNameCheck();
                // return;
                // 获取表单
                let menu = $("#menuForm").serialize();
                // ajax
                save(menu);
            });
        });

        function mNameCheck() {
            let mName = $("input[name='mName']").val();
            $.ajax({
                type: "GET",
                url: "/resource/check",
                dataType: "json",
                data: mName,
                success: function (res) {
                    if (res.obj === true) {
                        alert("当前资源名称不可用!");
                    }
                }
            })
        }
    </script>
</head>
<body>
<form id="menuForm" action="index.html" method="post" class="definewidth m20">
    <input type="hidden" name="mId"/>
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">资源名称</td>
            <td><input type="text" name="mName" onclick="mNameCheck"/></td>
        </tr>
        <tr>
            <td class="tableleft">url</td>
            <td><input type="text" name="mUrl"/></td>
        </tr>
        <tr>
            <td class="tableleft">是否有效</td>
            <td>
                <input type="radio" name="mState" value="0" checked/> 有效
                <input type="radio" name="mState" value="1"/> 无效
            </td>
        </tr>
        <tr>
            <td class="tableleft"></td>
            <td>
                <button id="b1" class="btn btn-primary" type="button">新增</button>&nbsp;&nbsp;<button
                    type="button" class="btn btn-success" name="backid" id="backid">返回列表
            </button>
            </td>
        </tr>
    </table>
</form>
</body>
</html>